home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility1 / gsview08.zip / INIT.C < prev    next >
C/C++ Source or Header  |  1993-06-10  |  17KB  |  497 lines

  1. /*
  2.  * init.c   -- Initialisation functions for GSVIEW.EXE,
  3.  *             a graphical interface for MS-Windows Ghostscript
  4.  * Copyright (C) 1993  Russell Lang
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  *   Author: Russell Lang
  21.  * Internet: rjl@monu1.cc.monash.edu.au
  22.  */
  23.  
  24. #define STRICT
  25. #include <windows.h>
  26. #include <windowsx.h>
  27. #include <commdlg.h>
  28. #include <shellapi.h>
  29. #include <mmsystem.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <ctype.h>
  34. #include <dir.h>
  35. #include <io.h>
  36. #define NeedFunctionPrototypes 1
  37. #include "ps.h"
  38. #include "gsview.h"
  39.  
  40. /* Open/Save File Dialog Box */
  41. OPENFILENAME ofn;
  42. char szOFilename[MAXSTR];    /* filename for OFN */
  43. char szOFilter[256];        /* filter for OFN */
  44. /* buttons */
  45. WNDPROC lpfnButtonWndProc;    /* default button WndProc */
  46. struct buttonlist {
  47.    HWND hbutton;
  48.    struct buttonlist *next;
  49. };
  50. struct buttonlist *buttonhead, *buttontail;
  51. int real_button_width;
  52.  
  53. /* Don't start another instance - use previous instance */
  54. void
  55. gsview_init0(LPSTR lpszCmdLine)
  56. {
  57.     HWND hwnd = FindWindow(szClassName, szAppName);
  58.     BringWindowToTop(hwnd);
  59.     if (lstrlen(lpszCmdLine) != 0) {
  60.         /* open file specified on command line */
  61.         LPSTR szFile = GlobalAllocPtr(GHND | GMEM_SHARE, lstrlen(lpszCmdLine)+1);
  62.         if (szFile) {
  63.         lstrcpy(szFile, lpszCmdLine);
  64.         PostMessage(hwnd, WM_COMMAND, IDM_DROP, (LPARAM)szFile);
  65.         }
  66.     }
  67. }
  68.  
  69. /* main initialisation */
  70. void
  71. gsview_init1(LPSTR lpszCmdLine)
  72. {
  73. WNDCLASS wndclass;
  74. WORD version = LOWORD(GetVersion());
  75. char *p;
  76. char workdir[MAXSTR];
  77. char filedir[MAXSTR];
  78.  
  79.     if ((LOBYTE(version)<<8) + HIBYTE(version) >= 0x30a)
  80.         is_win31 = TRUE;
  81.  
  82.     /* get path to help file */
  83.     GetModuleFileName(phInstance, szHelpName, sizeof(szHelpName));
  84.     if ((p = strrchr(szHelpName,'\\')) != (char *)NULL)
  85.         p++;
  86.     else
  87.         p = szHelpName;
  88.     LoadString(phInstance, IDS_HELPFILE, p, sizeof(szHelpName) - (p-szHelpName));
  89.  
  90.     /* help message for GetOpenFileName Dialog Box */
  91.     help_message = RegisterWindowMessage(HELPMSGSTRING);
  92.     LoadString(phInstance, IDS_TOPICROOT, szHelpTopic, sizeof(szHelpTopic));
  93.     
  94.     /* register the window class */
  95.     wndclass.style = CS_HREDRAW | CS_VREDRAW;
  96.     wndclass.lpfnWndProc = WndImgProc;
  97.     wndclass.cbClsExtra = 0;
  98.     wndclass.cbWndExtra = sizeof(LONG);
  99.     wndclass.hInstance = phInstance;
  100.     wndclass.hIcon = LoadIcon(phInstance,"gsview");
  101.     wndclass.hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW);
  102.     wndclass.hbrBackground =  GetStockObject(WHITE_BRUSH);
  103.     wndclass.lpszMenuName = NULL;
  104.     wndclass.lpszClassName = szClassName;
  105.     RegisterClass(&wndclass);
  106.  
  107.     /* defaults if entry not in gsview.ini */
  108.     strcpy(szGSwin, DEFAULT_GSCOMMAND);
  109.     img_origin.x = img_origin.y = CW_USEDEFAULT;
  110.     img_size.x = img_size.y = CW_USEDEFAULT;
  111.     xdpi = ydpi = DEFAULT_RESOLUTION;
  112.     settings = TRUE;
  113.     button_show = TRUE;
  114.     quick = TRUE;
  115.     timeout = DEFAULT_TIMEOUT;
  116.     save_dir = TRUE;
  117.     media = IDM_LETTER;
  118.     epsf_clip = FALSE;
  119.     orientation = IDM_PORTRAIT;
  120.     swap_landscape = FALSE;
  121.     hmenu = LoadMenu(phInstance, "gsview_menu");
  122.     haccel = LoadAccelerators(phInstance, "gsview_accel");
  123.     getcwd(workdir, sizeof(workdir));
  124.     /* read entries from gsview.ini */
  125.     read_profile();
  126.  
  127.     hwndimg = CreateWindow(szClassName, (LPSTR)szAppName,
  128.           WS_OVERLAPPEDWINDOW,
  129.           img_origin.x, img_origin.y, 
  130.           img_size.x, img_size.y, 
  131.           NULL, NULL, phInstance, (void FAR *)NULL);
  132.  
  133.     /* load DLL for sounds */
  134.     if (is_win31) {
  135.         /* MMSYSTEM.DLL requires Windows 3.1, so to allow gsview to run
  136.            under Windows 3.0 we can't use the import library */
  137.         hlib_mmsystem = LoadLibrary("MMSYSTEM.DLL");
  138.         if (hlib_mmsystem >= HINSTANCE_ERROR) {
  139.         lpfnSndPlaySound = (FPSPS)GetProcAddress(hlib_mmsystem, "sndPlaySound");
  140.         }
  141.         else {
  142.         gserror(IDS_SOUNDNOMM, NULL, MB_ICONEXCLAMATION, -1);
  143.         hlib_mmsystem = (HINSTANCE)NULL;
  144.         }
  145.     }
  146.  
  147.     if (lstrlen(lpszCmdLine) >= 2) {
  148.         if ( ((lpszCmdLine[0] == '/') || (lpszCmdLine[0] == '-'))
  149.          &&  ((lpszCmdLine[1] == 'D') || (lpszCmdLine[1] == 'd')) ) {
  150.         debug = TRUE;
  151.         lpszCmdLine += 2;
  152.         while (*lpszCmdLine && (*lpszCmdLine == ' '))
  153.             lpszCmdLine++;
  154.         }
  155.      }
  156.     if (lstrlen(lpszCmdLine) != 0) {
  157.         /* open file specified on command line */
  158.         LPSTR szFile = GlobalAllocPtr(GHND, lstrlen(lpszCmdLine)+1);
  159.         if (szFile) {
  160.         lstrcpy(szFile, lpszCmdLine);
  161.         PostMessage(hwndimg, WM_COMMAND, IDM_DROP, (LPARAM)szFile);
  162.         }
  163.         /* ignore last saved directory */
  164.         /* use directory of file if given, or work directory */
  165.         if ((lpszCmdLine[0] == '/') || (lpszCmdLine[0] == '-')) {
  166.         lpszCmdLine += 2;
  167.         while (*lpszCmdLine && (*lpszCmdLine == ' '))
  168.             lpszCmdLine++;
  169.         }
  170.         lstrcpy(filedir, lpszCmdLine);
  171.         if ( (p = strrchr(filedir, '\\')) == (char *)NULL ) {
  172.             if ( (p = strrchr(filedir, ':')) == (char *)NULL )
  173.             strcpy(filedir, workdir);  /* no path so use work directory */
  174.         else
  175.             *(++p) = '\0';
  176.         }
  177.         else
  178.         *(++p) = '\0';
  179.         if (!((strlen(filedir)==2) && isalpha(filedir[0]) && (filedir[1]==':')))
  180.             chdir(filedir);
  181.         if (isalpha(filedir[0]) && (filedir[1]==':'))
  182.         (void) setdisk(toupper(filedir[0])-'A');
  183.     }
  184.     play_sound(SOUND_START);
  185. }
  186.  
  187. /* create gsview window menu bar and buttons */
  188. void
  189. gsview_create()
  190. {
  191. int i;
  192. char cReplace;
  193. WNDCLASS wndclass;
  194. HGLOBAL hglobal;
  195. int FAR *pButtonID;
  196. TEXTMETRIC tm;
  197. HDC hdc;
  198. HWND hbutton;
  199. WNDPROC    lpfnMenuButtonProc;
  200. POINT char_size;        /* size of default text characters */
  201. POINT button_size, button_shift;
  202.  
  203.     /* setup OPENFILENAME struct */
  204.     if (!LoadString(phInstance, IDS_FILTER, szOFilter, sizeof(szOFilter)-1))
  205.         return;
  206.     cReplace = szOFilter[strlen(szOFilter)-1];
  207.     for (i=0; szOFilter[i] != '\0'; i++)
  208.         if (szOFilter[i] == cReplace)
  209.         szOFilter[i] = '\0';
  210.     ofn.lStructSize = sizeof(OPENFILENAME);
  211.     ofn.hwndOwner = hwndimg;
  212.     ofn.lpstrFilter = szOFilter;
  213.     ofn.nFilterIndex = FILTER_PS;
  214.     ofn.lpstrFile = szOFilename;
  215.     ofn.nMaxFile = sizeof(szOFilename);
  216.     ofn.lpstrFileTitle = (LPSTR)NULL;
  217.     ofn.nMaxFileTitle = 0;
  218.     ofn.lpstrTitle = (LPSTR)NULL;
  219.     ofn.lpstrInitialDir = (LPSTR)NULL;
  220.     ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_SHOWHELP;
  221.     LoadString(phInstance, IDS_TOPICROOT, szHelpTopic, sizeof(szHelpTopic));
  222.  
  223.     /* add menu to image window */
  224.     SetMenu(hwndimg, hmenu);
  225.  
  226.     /* get default text size */
  227.     hdc = GetDC(hwndimg);
  228.     GetTextMetrics(hdc,(LPTEXTMETRIC)&tm);
  229.     ReleaseDC(hwndimg,hdc);
  230.     char_size.x = tm.tmAveCharWidth;
  231.     char_size.y = tm.tmHeight;
  232.  
  233.     /* set size of info area, buttons and offset to child window */
  234.     info_rect.left = 0;
  235.     info_rect.right = info_rect.left + 60 * char_size.x;
  236.     info_rect.top = 0;
  237.     info_rect.bottom = char_size.y;
  238.     button_size.x = 24;
  239.     button_size.y = 24;
  240.     button_shift.x = 0;
  241.     button_shift.y = button_size.y - 1;
  242.     button_rect.top = info_rect.bottom;
  243.     button_rect.left = -1;
  244.     button_rect.right = button_size.x - 2;
  245.     button_rect.bottom = 0;        /* don't care */
  246.     real_button_width = button_rect.right;
  247.     if (!button_show)
  248.         button_rect.right = 0;
  249.     img_offset.x = button_rect.right + (button_show ? 1 : 0);
  250.     img_offset.y = info_rect.bottom + 1;
  251.     info_file.x = info_rect.left + 2;
  252.     info_file.y = 0;
  253.     info_page.x = info_rect.left + 34 * char_size.x + 2;
  254.     info_page.y = 0;
  255.     info_coord.left = info_rect.left + 20 * char_size.x;
  256.     info_coord.right = info_rect.left + 32 * char_size.x;
  257.     info_coord.top = 0;
  258.     info_coord.bottom = char_size.y;
  259.  
  260.     /* check menu items */
  261.     CheckMenuItem(hmenu, media, MF_BYCOMMAND | MF_CHECKED);
  262.     CheckMenuItem(hmenu, orientation, MF_BYCOMMAND | MF_CHECKED);
  263.     if (epsf_clip)
  264.         CheckMenuItem(hmenu, IDM_EPSFCLIP, MF_BYCOMMAND | MF_CHECKED);
  265.     if (epsf_warn)
  266.         CheckMenuItem(hmenu, IDM_EPSFWARN, MF_BYCOMMAND | MF_CHECKED);
  267.     if (swap_landscape)
  268.         CheckMenuItem(hmenu, IDM_SWAPLANDSCAPE, MF_BYCOMMAND | MF_CHECKED);
  269.     if (save_dir) 
  270.         CheckMenuItem(hmenu, IDM_SAVEDIR, MF_BYCOMMAND | MF_CHECKED);
  271.     if (button_show) 
  272.         CheckMenuItem(hmenu, IDM_BUTTONSHOW, MF_BYCOMMAND | MF_CHECKED);
  273.     if (quick) 
  274.         CheckMenuItem(hmenu, IDM_QUICK, MF_BYCOMMAND | MF_CHECKED);
  275.     if (redisplay) 
  276.         CheckMenuItem(hmenu, IDM_AUTOREDISPLAY, MF_BYCOMMAND | MF_CHECKED);
  277.     if (settings)
  278.         CheckMenuItem(hmenu, IDM_SAVESETTINGS, MF_BYCOMMAND | MF_CHECKED);
  279.  
  280.     hcWait = LoadCursor((HINSTANCE)NULL, IDC_WAIT);
  281.  
  282.     /* add buttons */
  283.     lpfnMenuButtonProc = (WNDPROC)MakeProcInstance((FARPROC)MenuButtonProc, phInstance);
  284.     GetClassInfo((HINSTANCE)NULL, "button", &wndclass);    /* get default button class info */
  285.     lpfnButtonWndProc = wndclass.lpfnWndProc;
  286.     
  287.     hglobal = LoadResource(phInstance, FindResource(phInstance, "gsview_button", RT_RCDATA));
  288.     if ( (pButtonID = (int FAR *)LockResource(hglobal)) == (int FAR *)NULL)
  289.         return;
  290.     
  291.     for (i=0; pButtonID[i]; i++) {
  292.         hbutton = CreateWindow("button", NULL,
  293.             WS_CHILD | (button_show ? WS_VISIBLE : 0) | BS_OWNERDRAW,
  294.             button_rect.left + i * button_shift.x,
  295.             button_rect.top  + i * button_shift.y,
  296.             button_size.x, button_size.y,
  297.             hwndimg, (HMENU)pButtonID[i],
  298.             phInstance, NULL);
  299.         SetWindowLong(hbutton, GWL_WNDPROC, (LONG)lpfnMenuButtonProc);
  300.         if (hbutton) {
  301.         if (buttonhead == (struct buttonlist *)NULL)
  302.             buttontail = buttonhead = (struct buttonlist *)malloc(sizeof(struct buttonlist));
  303.         else {
  304.             buttontail->next = (struct buttonlist *)malloc(sizeof(struct buttonlist)); 
  305.             buttontail = buttontail->next;
  306.         }
  307.         buttontail->hbutton = hbutton;
  308.         buttontail->next = NULL;
  309.         }
  310.     }
  311.     FreeResource(hglobal);
  312. }
  313.  
  314. void
  315. show_buttons(void)
  316. {
  317. struct buttonlist *bp = buttonhead;
  318. RECT rect;
  319.     button_rect.right = button_show ? real_button_width : 0;
  320.     img_offset.x = button_rect.right + (button_show ? 1 : 0);
  321.     if (!button_show) {
  322.         while (bp) {
  323.             ShowWindow(bp->hbutton, SW_HIDE);
  324.             bp = bp->next;
  325.         }
  326.         if (hwndimgchild == (HWND)NULL) {
  327.             GetClientRect(hwndimg, &rect);
  328.             rect.right = real_button_width + 1;
  329.             rect.top = button_rect.top;
  330.             InvalidateRect(hwndimg, &rect, TRUE);
  331.             UpdateWindow(hwndimg);
  332.         }
  333.     }
  334.     GetClientRect(hwndimg, &rect);
  335.     SetWindowPos(hwndimgchild, (HWND)NULL, rect.left+img_offset.x, rect.top+img_offset.y,
  336.         rect.right-img_offset.x, rect.bottom-img_offset.y, 
  337.         SWP_NOZORDER | SWP_NOACTIVATE);
  338.     rect.right = real_button_width + 1;
  339.     rect.top = button_rect.top;
  340.     if (button_show) {
  341.         InvalidateRect(hwndimg, &rect, FALSE);
  342.         UpdateWindow(hwndimg);
  343.         while (bp) {
  344.             ShowWindow(bp->hbutton, SW_SHOWNA);
  345.             bp = bp->next;
  346.         }
  347.     }
  348. }
  349.  
  350. /* read settings fron INI file */
  351. void
  352. read_profile()
  353. {
  354. int i;
  355. char profile[128];
  356. LPSTR file = INIFILE;
  357. LPSTR section = INISECTION;
  358.     GetPrivateProfileString(section, "Origin", "", profile, sizeof(profile), file);
  359.     if (sscanf(profile,"%d %d", &img_origin.x, &img_origin.y) != 2) {
  360.         img_origin.x = CW_USEDEFAULT;
  361.         img_origin.y = CW_USEDEFAULT;
  362.     }
  363.     GetPrivateProfileString(section, "Size", "", profile, sizeof(profile), file);
  364.     if (sscanf(profile,"%d %d", &img_size.x, &img_size.y) != 2) {
  365.         img_origin.x = CW_USEDEFAULT;
  366.         img_origin.y = CW_USEDEFAULT;
  367.     }
  368.     GetPrivateProfileString(section, "SaveSettings", "", profile, sizeof(profile), file);
  369.     if (sscanf(profile,"%d", &i) == 1)
  370.         settings = i;
  371.     GetPrivateProfileString(section, "ButtonBar", "", profile, sizeof(profile), file);
  372.     if (sscanf(profile,"%d", &i) == 1)
  373.         button_show = i;
  374.     GetPrivateProfileString(section, "Resolution", "", profile, sizeof(profile), file);
  375.     if (sscanf(profile,"%f %f", &xdpi, &ydpi) != 2) {
  376.         xdpi = DEFAULT_RESOLUTION;
  377.         ydpi = DEFAULT_RESOLUTION;
  378.     }
  379.     GetPrivateProfileString(section, "Media", "", profile, sizeof(profile), file);
  380.     if (strlen(profile)!=0) {
  381.         char medianame[20];
  382.         for (i=IDM_LETTER; i<IDM_USERSIZE; i++) {
  383.             GetMenuString(hmenu, i, medianame, sizeof(medianame), MF_BYCOMMAND);
  384.             if (!stricmp(medianame, profile)) {
  385.                 break;
  386.             }
  387.         }
  388.         media = i;
  389.         }
  390.     GetPrivateProfileString(section, "UserSize", "", profile, sizeof(profile), file);
  391.     if (sscanf(profile,"%d %d", &user_width, &user_height) != 2) {
  392.         /* this gives 640x480 pixels at 96dpi */
  393.         user_width = 480;
  394.         user_height = 360;
  395.     }
  396.     GetPrivateProfileString(section, "EpsfClip", "", profile, sizeof(profile), file);
  397.     if (sscanf(profile,"%d", &i) == 1)
  398.         epsf_clip = i;
  399.     GetPrivateProfileString(section, "EpsfWarn", "", profile, sizeof(profile), file);
  400.     if (sscanf(profile,"%d", &i) == 1)
  401.         epsf_warn = i;
  402.     GetPrivateProfileString(section, "Orientation", "", profile, sizeof(profile), file);
  403.     if (sscanf(profile,"%d", &i) == 1)
  404.         orientation = i+IDM_PORTRAIT;
  405.     GetPrivateProfileString(section, "SwapLandscape", "", profile, sizeof(profile), file);
  406.     if (sscanf(profile,"%d", &i) == 1)
  407.         swap_landscape = i;
  408.     GetPrivateProfileString(section, "QuickOpen", "", profile, sizeof(profile), file);
  409.     if (sscanf(profile,"%d", &i) == 1)
  410.         quick = i;
  411.     GetPrivateProfileString(section, "AutoRedisplay", "", profile, sizeof(profile), file);
  412.     if (sscanf(profile,"%d", &i) == 1)
  413.         redisplay = i;
  414.     GetPrivateProfileString(section, "Timeout", "", profile, sizeof(profile), file);
  415.     if (sscanf(profile,"%d", &i) == 1)
  416.         timeout = i;
  417.     if (timeout == 0)
  418.         timeout = 120;
  419.     GetPrivateProfileString(section, "SaveLastDir", "", profile, sizeof(profile), file);
  420.     if (sscanf(profile,"%d", &i) == 1)
  421.         save_dir = i;
  422.     if (save_dir) {
  423.         GetPrivateProfileString(section, "LastDir", "", profile, sizeof(profile), file);
  424.         if (!((strlen(profile)==2) && isalpha(profile[0]) && (profile[1]==':')))
  425.             chdir(profile);
  426.         if (isalpha(profile[0]) && (profile[1]==':'))
  427.         (void) setdisk(toupper(profile[0])-'A');
  428.     }
  429.     GetPrivateProfileString(section, "Ghostscript", "", profile, sizeof(profile), file);
  430.     if (profile[0] == '\0')
  431.         strcpy(szGSwin, DEFAULT_GSCOMMAND);
  432.     else
  433.         strcpy(szGSwin, profile);
  434.     GetPrivateProfileString(section, "Printer", ",", profile, sizeof(profile), file);
  435.     strcpy(device_name, strtok(profile,","));
  436.     strcpy(device_resolution, strtok(NULL, ","));
  437.     for (i=0; i<NUMSOUND; i++) {
  438.         GetPrivateProfileString(section, sound[i].entry, sound[i].file, profile, sizeof(profile), file);
  439.         strcpy(sound[i].file, profile);
  440.     }
  441. }
  442.  
  443. /* write settings to INI file */
  444. void
  445. write_profile()
  446. {
  447. char profile[MAXSTR];
  448. LPSTR file = INIFILE;
  449. LPSTR section = INISECTION;
  450. int i;
  451.     sprintf(profile, "%d %d", img_origin.x, img_origin.y);
  452.     WritePrivateProfileString(section, "Origin", profile, file);
  453.     sprintf(profile, "%d %d", img_size.x, img_size.y);
  454.     WritePrivateProfileString(section, "Size", profile, file);
  455.     sprintf(profile, "%d", settings);
  456.     WritePrivateProfileString(section, "SaveSettings", profile, file);
  457.     sprintf(profile, "%d", button_show);
  458.     WritePrivateProfileString(section, "ButtonBar", profile, file);
  459.     sprintf(profile, "%g %g", xdpi, ydpi);
  460.     WritePrivateProfileString(section, "Resolution", profile, file);
  461.     if (media == IDM_USERSIZE)
  462.         strcpy(profile, "User Defined");
  463.     else
  464.         GetMenuString(hmenu, media, profile, sizeof(profile), MF_BYCOMMAND);
  465.     WritePrivateProfileString(section, "Media", profile, file);
  466.     sprintf(profile, "%u %u", user_width, user_height);
  467.     WritePrivateProfileString(section, "UserSize", profile, file);
  468.     sprintf(profile, "%d", epsf_clip);
  469.     WritePrivateProfileString(section, "EpsfClip", profile, file);
  470.     sprintf(profile, "%d", epsf_warn);
  471.     WritePrivateProfileString(section, "EpsfWarn", profile, file);
  472.     sprintf(profile, "%d", orientation - IDM_PORTRAIT);
  473.     WritePrivateProfileString(section, "Orientation", profile, file);
  474.     sprintf(profile, "%d", swap_landscape);
  475.     WritePrivateProfileString(section, "SwapLandscape", profile, file);
  476.     sprintf(profile, "%d", quick);
  477.     WritePrivateProfileString(section, "QuickOpen", profile, file);
  478.     sprintf(profile, "%d", redisplay);
  479.     WritePrivateProfileString(section, "AutoRedisplay", profile, file);
  480.     sprintf(profile, "%d", timeout);
  481.     WritePrivateProfileString(section, "Timeout", profile, file);
  482.     sprintf(profile, "%d", save_dir);
  483.     WritePrivateProfileString(section, "SaveLastDir", profile, file);
  484.     if (save_dir) {
  485.         getcwd(profile, sizeof(profile));
  486.         WritePrivateProfileString(section, "LastDir", profile, file);
  487.     }
  488.     WritePrivateProfileString(section, "Ghostscript", szGSwin, file);
  489.     if (device_name[0] != '\0') {
  490.         sprintf(profile,"%s,%s",device_name,device_resolution);
  491.         WritePrivateProfileString(section, "Printer", profile, file);
  492.     }
  493.     for (i=0; i<NUMSOUND; i++)
  494.         WritePrivateProfileString(section, sound[i].entry, sound[i].file, file);
  495. }
  496.  
  497.